﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Display.PopulationUI {
    import flash.events.*;
    import flash.display.*;
    import Events.*;
    import org.aswing.*;
    import Classes.util.*;
    import org.aswing.geom.*;
    import Display.*;
    import Display.MarketUI.*;
    import Display.aswingui.*;

    public class PopulationMunicipalCell extends DataItemCell {

        public static const PADDING:int = 8;

        protected var m_iconLoaded:Boolean = false;
        protected var m_assetSwfLoaded:Boolean = false;
        protected var m_comObject:Object;

        public function PopulationMunicipalCell(_arg1:LayoutManager=null){
            super(new SoftBoxLayout(SoftBoxLayout.Y_AXIS, 0, SoftBoxLayout.CENTER));
            setPreferredSize(new IntDimension((Catalog.CARD_WIDTH + (2 * PADDING)), Catalog.CARD_HEIGHT));
            setMaximumSize(new IntDimension((Catalog.CARD_WIDTH + (2 * PADDING)), Catalog.CARD_HEIGHT));
            setMinimumSize(new IntDimension((Catalog.CARD_WIDTH + (2 * PADDING)), Catalog.CARD_HEIGHT));
            this.addEventListener(MouseEvent.MOUSE_UP, this.onMouseUp, false, 0, true);
            this.addEventListener(MouseEvent.MOUSE_OVER, this.onMouseOver, false, 0, true);
            this.addEventListener(MouseEvent.MOUSE_OUT, this.onMouseOut, false, 0, true);
        }
        override public function setCellValue(_arg1):void{
            super.setCellValue(_arg1);
            Global.delayedAssets.get(DelayedAssetLoader.POPULATION_ASSETS, this.onAssetSwfLoad);
        }
        override protected function onIconLoad(_arg1:Event):void{
            if (((m_loader) && (m_loader.content))){
                m_itemIcon = m_loader.content;
            };
            m_itemIcon.scaleX = (m_itemIcon.scaleY = scaleToFit(m_itemIcon));
            this.m_iconLoaded = true;
            if (((this.m_iconLoaded) && (this.m_assetSwfLoaded))){
                this.onAllAssetsLoaded();
            };
        }
        protected function onAssetSwfLoad(_arg1:DisplayObject, _arg2:String):void{
            this.m_comObject = _arg1;
            this.m_assetSwfLoaded = true;
            if (((this.m_iconLoaded) && (this.m_assetSwfLoaded))){
                this.onAllAssetsLoaded();
            };
        }
        protected function onAllAssetsLoaded():void{
            this.initializeCell();
            setGridListCellStatus(m_gridList, false, m_index);
        }
        override protected function initializeCell():void{
            var _local1:JPanel = ASwingHelper.makeSoftBoxJPanel(AsWingConstants.CENTER);
            var _local2:JPanel = ASwingHelper.makeSoftBoxJPanelVertical(AsWingConstants.CENTER);
            _local2.setPreferredSize(new IntDimension(Catalog.CARD_WIDTH, Catalog.CARD_HEIGHT));
            _local2.setMaximumSize(new IntDimension(Catalog.CARD_WIDTH, Catalog.CARD_HEIGHT));
            _local2.setMinimumSize(new IntDimension(Catalog.CARD_WIDTH, Catalog.CARD_HEIGHT));
            var _local3:DisplayObject = (new this.m_comObject.population_item() as DisplayObject);
            var _local4:MarginBackground = new MarginBackground(_local3);
            _local2.setBackgroundDecorator(_local4);
            var _local5:AssetPane = new AssetPane(m_itemIcon);
            ASwingHelper.prepare(_local5);
            var _local6:Number = ((Catalog.CARD_HEIGHT - m_itemIcon.height) / 2);
            _local2.append(ASwingHelper.verticalStrut(_local6));
            _local2.append(_local5);
            ASwingHelper.prepare(_local2);
            _local1.append(ASwingHelper.horizontalStrut(PADDING));
            _local1.append(_local2);
            _local1.append(ASwingHelper.horizontalStrut(PADDING));
            ASwingHelper.prepare(_local1);
            this.append(_local1);
            ASwingHelper.prepare(this);
        }
        protected function onMouseOver(_arg1:MouseEvent):void{
        }
        protected function onMouseOut(_arg1:MouseEvent):void{
        }
        protected function onMouseUp(_arg1:MouseEvent):void{
            this.dispatchEvent(new DataItemEvent(DataItemEvent.CLOSE_DIALOG, m_item, null, true));
        }

    }
}//package Display.PopulationUI 
